package com.beifu.manager.service.assetmodelservice.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.beifu.manager.dao.AssetInPlanMapper;
import com.beifu.manager.dao.AssetModelMapper;
import com.beifu.manager.dao.RoleMapper;
import com.beifu.manager.model.AssetModel;
import com.beifu.manager.model.AssetModelExample;
import com.beifu.manager.service.assetmodelservice.AssetModelService;
import com.utils.PageUtils;

/**
 * 
* Title: RoleServiceImpl
* Description:
* @author    BaiBing
* @date      2018年6月10日
 */
@Service
public class AssetModelServiceImpl implements AssetModelService {

    @Autowired
    private RoleMapper roleMapper;
    
    @Autowired
    private AssetModelMapper assetModelMapper;
    
    @Autowired
    private AssetInPlanMapper assetInPlanMapper;

    @Override
    public PageUtils getAssetModelPage(PageUtils page){
    	 AssetModelExample example = (AssetModelExample) page.getQueryParames();
    	 List<AssetModel> list = assetModelMapper.getAssetModelPage((page.getPage()-1)*page.getLimit(),page.getLimit(), example);
    	 int count = assetModelMapper.countByExample(example);
         page.setList(list);
         page.setCountNum(count);
         return page;
	}

	@Override
	public void createAssetModel(String assetModelName, String assetTypeSelect) {
		AssetModel assetModel = new AssetModel();
		assetModel.setAssetModelName(assetModelName);
		assetModel.setAssetTypeId(Integer.valueOf(assetTypeSelect));
		assetModelMapper.insert(assetModel);
	}

	@Override
	public List<AssetModel> getAssetModelByAssetType(String assetTypeID) {
		AssetModelExample example = new AssetModelExample();
		example.createCriteria().andAssetTypeIdEqualTo(Integer.valueOf(assetTypeID));
		return assetModelMapper.selectByExample(example);
	}

	
}
